Conditions | 4 |
Total Lines | 21 |
Code Lines | 18 |
Lines | 0 |
Ratio | 0 % |
Tests | 11 |
CRAP Score | 4 |
Changes | 0 |
1 | import Tweet from '../entities/Tweet'; |
||
10 | async run(args: runRetweetArgs): Promise<void> { |
||
11 | 5 | const {tweet, onSuccess} = args; |
|
12 | |||
13 | 5 | this.debug(`Retweeting tweet with id: '${tweet.rawTweet.id_str}' ...`); |
|
14 | 5 | const result = await this.twit.post('statuses/retweet/:id', { |
|
15 | id: tweet.rawTweet.id_str |
||
16 | }); |
||
17 | |||
18 | 4 | if (this.isSuccessResponse(result)) { |
|
19 | 2 | this.debug('Retweeted!'); |
|
20 | |||
21 | 2 | if (onSuccess) { |
|
22 | 1 | await onSuccess(tweet); |
|
23 | } |
||
24 | } else { |
||
25 | 2 | this.debug('Cannot retweet.'); |
|
26 | 2 | if (Helper.objectExists(result.resp.statusMessage)) { |
|
27 | 1 | this.debug(result.resp.statusMessage); |
|
28 | } |
||
29 | |||
30 | 2 | throw new Error('Cannot retweet'); |
|
31 | } |
||
33 | } |